package com.architecture.core.web.actions;

import com.architecture.core.web.vo.PermissionVO;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.stereotype.Controller;

/**
 * Created with IntelliJ IDEA.
 * User: hjg
 * Date: 12-11-20
 * Time: 下午2:48
 * To change this template use File | Settings | File Templates.
 */
@Controller("permissionAction")
@Results({
        @Result(name = "create_success", location = "front/login.jsp"),
        @Result(name = "create_error", location = "front/login.jsp"),
        @Result(name = "update_success", location = "front/login.jsp"),
        @Result(name = "update_error", location = "front/login.jsp"),
        @Result(name = "delete_success", location = "front/login.jsp"),
        @Result(name = "delete_error", location = "front/login.jsp")
})
public class PermissionAction extends AbstractAction {

//    @Resource
//    private BasePermissionService basePermissionService;

    private PermissionVO permissionVO = new PermissionVO();

    @Override
    @Action(value = "permission")
    public String execute() throws Exception {
        return null;    //To change body of overridden methods use File | Settings | File Templates.
    }

//    @Action(value = "create_permission")
//    public String createPermission() throws Exception {
//
//        try {
//            this.basePermissionService.createPermission(super.getSessionMap().get(super.CURRENT_ID).toString(), this.getPermissionVO().getPermission());
//            return super.CREATE_SUCCESS;
//        } catch (ErrException err) {
//            err.printStackTrace();
//            super.addActionError(err.getMessage());
//        }
//        return super.CREATE_ERROR;
//    }
//
//    @Action(value = "update_permission")
//    public String updatePermission() throws Exception {
//        try {
//            this.basePermissionService.updatePermission(super.getSessionMap().get(super.CURRENT_ID).toString(), this.getPermissionVO().getPermission());
//            return super.UPDATE_SUCCESS;
//        } catch (ErrException err) {
//            err.printStackTrace();
//            super.addActionError(err.getMessage());
//        }
//        return super.UPDATE_ERROR;
//    }
//
//    @Action(value = "delete_permission")
//    public String deletePermission() throws Exception {
//        try {
//            this.basePermissionService.deletePermission(super.getSessionMap().get(super.CURRENT_ID).toString(), this.getPermissionVO().getPermission().getId());
//            return super.DELETE_SUCCESS;
//        } catch (ErrException err) {
//            err.printStackTrace();
//            super.addActionError(err.getMessage());
//        }
//        return super.DELETE_ERROR;
//    }

    public PermissionVO getPermissionVO() {
        return permissionVO;
    }

    public void setPermissionVO(PermissionVO permissionVO) {
        this.permissionVO = permissionVO;
    }
}
